home *** CD-ROM | disk | FTP | other *** search
/ Australian Personal Computer 2000 July / CD 3 / redhat-6.2.iso / RedHat / instimage / usr / lib / anaconda / iw / keyboard.py < prev    next >
Encoding:
Python Source  |  2000-03-08  |  4.4 KB  |  123 lines

  1. from gtk import *
  2. from iw import *
  3. import xkb
  4. import string
  5. import keyboard
  6. from translate import _
  7.  
  8. class KeyboardWindow (InstallWindow):
  9.  
  10.     def __init__ (self, ics):
  11.     InstallWindow.__init__ (self, ics)
  12.  
  13.         ics.setTitle (_("Keyboard Configuration"))
  14.         ics.readHTML ("kybd")
  15.         ics.setNextEnabled (TRUE)
  16.     self.kb = xkb.XKB ()
  17.     self.rules = self.kb.getRules ()
  18.     rules = self.kb.getRulesBase ()
  19.     self.rulesbase = rules[string.rfind (rules, "/")+1:]
  20.         self.model = "pc101"
  21.         self.layout = "en_US"
  22.     if self.todo.keyboard.type == "Sun":
  23.         self.model = self.todo.keyboard.model
  24.         self.layout = self.todo.keyboard.layout
  25.         self.variant = ""
  26.         self.hasrun = 0
  27.  
  28.     def getNext (self):
  29.         if self.hasrun:
  30.             self.todo.x.setKeyboard (self.rulesbase, self.model,
  31.                                      self.layout, self.variant, "")
  32.             self.todo.keyboard.setfromx (self.model, self.layout)
  33.         return None
  34.  
  35.     def select_row (self, clist, row, col, event):
  36.     self.model = self.modelList.get_row_data (self.modelList.selection[0])
  37.     self.layout = self.layoutList.get_row_data (self.layoutList.selection[0])
  38.     self.variant = self.variantList.get_row_data (self.variantList.selection[0])
  39.         
  40.     self.kb.setRule (self.model, self.layout, self.variant, "complete")
  41.  
  42.     def getScreen (self):
  43.     box = GtkVBox (FALSE, 5)
  44.         im = self.ics.readPixmap ("gnome-keyboard.png")
  45.         if im:
  46.             im.render ()
  47.             pix = im.make_pixmap ()
  48.             a = GtkAlignment ()
  49.             a.add (pix)
  50.             a.set (0.0, 0.0, 0.0, 0.0)
  51.             box.pack_start (a, FALSE)
  52.  
  53.     def moveto (widget, *args):
  54.             widget.moveto (widget.selection[0], 0, 0.5, 0.5)
  55.  
  56.     box.pack_start (GtkLabel (_("Model")), FALSE)
  57.         sw = GtkScrolledWindow ()
  58.         sw.set_policy (POLICY_AUTOMATIC, POLICY_AUTOMATIC)
  59.         self.modelList = GtkCList ()
  60.     self.modelList.freeze ()
  61.         self.modelList.set_selection_mode (SELECTION_BROWSE)
  62.         for (key, model) in self.rules[0].items ():
  63.             loc = self.modelList.append ((model,))
  64.         self.modelList.set_row_data (loc, key)
  65.             if key == self.model:
  66.                 self.modelList.select_row (loc, 0)
  67.         self.modelList.sort ()
  68.         self.modelList.connect ("select_row", self.select_row)
  69.         self.modelList.columns_autosize ()
  70.         self.modelList.connect_after ("size_allocate", moveto)
  71.     self.modelList.thaw ()
  72.         sw.add (self.modelList)
  73.     box.pack_start (sw, TRUE)
  74.  
  75.     box.pack_start (GtkLabel (_("Layout")), FALSE)
  76.         sw = GtkScrolledWindow ()
  77.         sw.set_policy (POLICY_AUTOMATIC, POLICY_AUTOMATIC)
  78.         self.layoutList = GtkCList ()
  79.     self.layoutList.freeze ()
  80.         self.layoutList.set_selection_mode (SELECTION_BROWSE)
  81.         for (key, layout) in self.rules[1].items ():
  82.             loc = self.layoutList.append ((layout,))
  83.         self.layoutList.set_row_data (loc, key)
  84.             if key == self.layout:
  85.                 self.layoutList.select_row (loc, 0)
  86.         self.layoutList.sort ()
  87.         self.layoutList.connect ("select_row", self.select_row)
  88.         self.layoutList.columns_autosize ()
  89.     self.layoutList.connect_after ("size_allocate", moveto)
  90.     self.layoutList.thaw ()
  91.         sw.add (self.layoutList)
  92.     box.pack_start (sw, TRUE)
  93.  
  94.     box.pack_start (GtkLabel (_("Dead Keys")), FALSE)
  95.         sw = GtkScrolledWindow ()
  96.         sw.set_policy (POLICY_AUTOMATIC, POLICY_AUTOMATIC)
  97.         self.variantList = GtkCList ()
  98.         self.variantList.set_selection_mode (SELECTION_BROWSE)
  99. #  For now, the only variant is deadkeys, so we'll just handle that
  100. #  as special case, so the text can be less confusing.
  101. #        self.variantList.append (("None",))
  102. #        for (key, variant) in self.rules[2].items ():
  103.         for (key, variant) in ((None, (_("Enable dead keys"))),
  104.                                ("nodeadkeys", (_("Disable dead keys")))):
  105.             loc = self.variantList.append ((variant,))
  106.         self.variantList.set_row_data (loc, key)
  107.         self.variantList.sort ()
  108.         self.variantList.connect ("select_row", self.select_row)
  109.         self.variantList.columns_autosize ()
  110.         sw.add (self.variantList)
  111.     box.pack_start (sw, FALSE)
  112.  
  113.         label = GtkLabel (_("Test your selection here:"))
  114.         label.set_alignment (0.0, 0.5)
  115.         box.pack_start (label, FALSE)
  116.  
  117.         entry = GtkEntry ()
  118.         box.pack_start (entry, FALSE)
  119.  
  120.         box.set_border_width (5)
  121.         self.hasrun = 1
  122.         return box
  123.